# Contributor: Alex Denes <caskd@redxen.eu>
# Maintainer:
pkgname=loki-mq
pkgver=1.2.2
pkgrel=1
pkgdesc="Communications layer used for both the Loki storage server and lokid"
url="https://lokinet.org/"
arch="x86_64 x86 aarch64 armv7" # ppc64le and s390x fail check()
license="BSD-3-Clause"
makedepends="cmake catch2 libsodium-dev>=1.0.18 cppzmq zeromq-dev"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/loki-project/loki-mq/archive/v$pkgver.tar.gz
	001-use-system-provided-catch2.patch
	002-use-system-headers-zeromq.patch
"
case "$CARCH" in
	x86|armv7|aarch64)
		# x86 and armv7 hang on a few tests
		# aarch64 gives inconsistent test results
		options="$options !check"
	;;
esac
subpackages="$pkgname-dev"
builddir="$srcdir/loki-mq-$pkgver"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -S . -B build/ \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_SHARED_LIBS=ON \
		-DLOKIMQ_BUILD_TESTS=ON \
		-DLOKIMQ_INSTALL_CPPZMQ=OFF
	make -C build
}

check() {
	make check -C build
}

package() {
	DESTDIR="$pkgdir" make install -C build
}

sha512sums="cd43bf9b342e39f4c49196ffced3c0e94b9f46f53f367cd21337090b84224b1a83c4f850745e921424fad619bfed606cd39d521b4de1da9e3ad2e5b9e3ccda24  loki-mq-1.2.2.tar.gz
e445ed0efaffeb68fff19c0146361b9574409eb3cb24d6888a7a8062bd0ce1cdac6358fef4b130c4333db0a6b729c4a021ffd2ce4768bde0644d65f9b127d926  001-use-system-provided-catch2.patch
2858495823d9902acca09430b06303b917a1fe84819a467ae62412eab0804e2848c6487e6c59a726c7731a7f22867f7aaeaaef028cab3d2b14b5c936ce46cfeb  002-use-system-headers-zeromq.patch"
